package com.atguigu.jxc.controller;

import com.atguigu.jxc.annotation.Log;
import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.PurchaseList;
import com.atguigu.jxc.service.PurchaseListGoodsService;
import com.atguigu.jxc.to.PurchaseCountTo;
import com.atguigu.jxc.to.PurchaseTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * @ClassName:purchaseListGoodsController
 * @Version: 1.0
 * @CreateAt:2021/3/8 10:25
 * @Author: ✨HanSan·胡✨
 * @Description:进货单Controller层
 */
@RestController
@RequestMapping("/purchaseListGoods")
public class PurchaseListGoodsController {
    @Autowired
    private PurchaseListGoodsService purchaseListGoodsService;
    
    /**
     * @Description: //TODO 进货单保存
     * @Param: []
     * @return: com.atguigu.jxc.domain.ServiceVO 
     * @Version: 1.0
     * @Date: 2021/3/8 10:27        
     * @Author: HanSan·胡
     **/
    @Log(logType = "新增操作",logContent = "进货单保存")
    @PostMapping("/save")
    public ServiceVO save(PurchaseList purchaseList, String purchaseListGoodsStr, HttpSession session){
        ServiceVO serviceVO = purchaseListGoodsService.save(purchaseList,purchaseListGoodsStr,session);
        return serviceVO;
    }

    /**
     * @Description: //TODO 进货单列表展示（可条件查询：单据号模糊、供应商、是否付款和日期区间）
     * @Param: []
     * @return: com.atguigu.jxc.domain.ServiceVO
     * @Version: 1.0
     * @Date: 2021/3/8 10:27
     * @Author: HanSan·胡
     **/
    @Log(logType = "查询操作",logContent = "进货单列表展示")
    @PostMapping("/list")
    public Map list(PurchaseTo purchaseTo){
        Map map = purchaseListGoodsService.listByPage(purchaseTo);

        return map;
    }

    /**
     * @Description: //TODO 查询进货单商品信息.
     * @Param: []
     * @return: com.atguigu.jxc.domain.ServiceVO
     * @Version: 1.0
     * @Date: 2021/3/8 10:27
     * @Author: HanSan·胡
     **/
    @Log(logType = "查询操作",logContent = "查询进货单商品信息")
    @PostMapping("/goodsList")
    public Map goodsList(Integer purchaseListId){
        Map map = purchaseListGoodsService.goodsList(purchaseListId);
        return map;
    }

    /**
     * @Description: //TODO 进货单删除
     * @Param: []
     * @return: com.atguigu.jxc.domain.ServiceVO
     * @Version: 1.0
     * @Date: 2021/3/8 10:27
     * @Author: HanSan·胡
     **/
    @Log(logType = "删除操作",logContent = "进货单删除")
    @PostMapping("/delete")
    public ServiceVO delete(Integer purchaseListId){
       return purchaseListGoodsService.delete(purchaseListId);
    }

    /**
     * @Description: //TODO 支付结算（修改进货单付款状态）
     * @Param: []
     * @return: com.atguigu.jxc.domain.ServiceVO
     * @Version: 1.0
     * @Date: 2021/3/8 10:27
     * @Author: HanSan·胡
     **/
    @Log(logType = "更新操作",logContent = "修改进货单付款状态")
    @PostMapping("/updateState")
    public ServiceVO updateState(Integer purchaseListId){
        return purchaseListGoodsService.updateState(purchaseListId);
    }

    /**
     * @Description: //TODO 进货统计（可根据 商品类别、商品编码或名称 条件查询）
     * @Param: []
     * @return: com.atguigu.jxc.domain.ServiceVO
     * @Version: 1.0
     * @Date: 2021/3/8 10:27
     * @Author: HanSan·胡
     **/
    @Log(logType = "查询操作",logContent = "进货统计")
    @PostMapping("/count")
    public List<Map> count(PurchaseCountTo purchaseCountTo){
        return purchaseListGoodsService.count(purchaseCountTo);
    }







}
